/*
 PureMVC AS3 Demo - Flex CafeTownsend
 Copyright (c) 2007-08 Michael Ramirez <michael.ramirez@puremvc.org>
 Parts Copyright (c) 2005-07 Adobe Systems, Inc. 
 Your reuse is governed by the Creative Commons Attribution 3.0 License
 */
/*
 Copyright 2011 The Apache Software Foundation

 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/
package idv.takeshi
{
    import org.puremvc.as3.interfaces.*;
    import org.puremvc.as3.patterns.proxy.*;
    import org.puremvc.as3.patterns.facade.*;

    import idv.takeshi.view.*;
    import idv.takeshi.model.*;
    import idv.takeshi.controller.*;

    /**
     * A concrete <code>Facade</code> for the <code>CafeTownsend</code> application.
     * <P>
     * The main job of the <code>ApplicationFacade</code> is to act as a single 
     * place for mediators, proxies and commands to access and communicate
     * with each other without having to interact with the Model, View, and
     * Controller classes directly. All this capability it inherits from 
     * the PureMVC Facade class.</P>
     * 
     * <P>
     * This concrete Facade subclass is also a central place to define 
     * notification constants which will be shared among commands, proxies and
     * mediators, as well as initializing the controller with Command to 
     * Notification mappings.</P>
     */
    public class ApplicationFacade extends Facade
    {
        
		private static var _amfEndPoint:String 				= "/trainingFlexSpringiBatisWebAp01/messagebroker/amf";
		
        // Notification name constants
        public static const STARTUP:String 					= "startup";
        public static const SHUTDOWN:String 				= "shutdown";
		public static const APP_LOGOUT:String 				= "appLogout";
		
		public static const APP_LOGIN:String 				= "appLogin";
		public static const APP_LOGIN_SUCCESS:String 		= "appLoginSuccess";
		public static const APP_LOGIN_FAILED:String 		= "appLoginFailed";
		
		public static const LOAD_PERSONS:String				= "loadPersons";
		public static const LOAD_PERSONS_SUCCESS:String		= "loadPersonsSuccess";
        public static const LOAD_PERSONS_FAILED:String		= "loadPersonsFailed";
		
		public static const LOAD_ROLES:String				= "loadRoles";
		public static const LOAD_ROLES_SUCCESS:String		= "loadRolesSuccess";
		public static const LOAD_ROLES_FAILED:String		= "loadRolesFailed";
		
		public static const VIEW_PERSON_LOGIN:String		= "viewPersonLogin";
		public static const VIEW_PERSON_LIST:String			= "viewPersonList";
		public static const VIEW_PERSON_DETAIL:String		= "viewPersonDetail";
		
		public static const ADD_PERSON:String				= "addPerson";
		public static const ADD_PERSON_SUCCESS:String		= "addPersonSuccess";
		public static const ADD_PERSON_FAILED:String		= "addPersonFailed";
		
		public static const UPDATE_PERSON:String			= "updatePerson";
		public static const UPDATE_PERSON_SUCCESS:String	= "updatePersonSuccess";
		public static const UPDATE_PERSON_FAILED:String		= "updatePersonFailed";
		
		public static const DELETE_PERSON:String			= "deletePerson";
		public static const DELETE_PERSON_SUCCESS:String	= "deletePersonSuccess";
		public static const DELETE_PERSON_FAILED:String		= "deletePersonFailed";
        /**
         * Singleton ApplicationFacade Factory Method
         */
        public static function getInstance() : ApplicationFacade 
		{
            if ( instance == null ) instance = new ApplicationFacade( );
            return instance as ApplicationFacade;
        }

        /**
         * Register Commands with the Controller 
         */
        override protected function initializeController( ) : void 
        {
            super.initializeController(); 
            registerCommand( STARTUP, ApplicationStartupCommand );
        }
        
        public function startup( app:Index ):void
        {
        	sendNotification( STARTUP, app );
        }

		public static function get amfEndPoint():String
		{
			return _amfEndPoint;
		}

		public static function set amfEndPoint(value:String):void
		{
			_amfEndPoint = value;
		}

    }
}
